package com.cute4j.diffs.javaswing;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

/**
 * Action Listener Example.
 */
public class ActionListenerExample {

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {    
        JFrame frame = new JFrame("Hello World");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JButton button = new JButton("Close");
        button.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
        frame.getContentPane().add(button);
        frame.pack();
        frame.setVisible(true);
      }
    });
  }

}
